package my.project.service;

import my.project.dao.UserDao;
import my.project.entity.UserEntity;
import my.spring.annotation.Resource;
import my.spring.annotation.Service;

import java.util.List;

/**
 * 用户服务
 */
@Service
public class UserService {
    @Resource
    private UserDao userDao;

    public UserEntity login(String username, String password) {
        UserEntity userEntity = userDao.findOneByUserName(username);
        if (userEntity != null && password.equals(userEntity.getPassword())) {
            return userEntity;
        } else {
            return null;
        }
    }

    public List<UserEntity> findAll() {
        return userDao.findAll();
    }
}
